package com.czkevin.cif.commands.main;

import com.czkevin.cif.CIFSubCommand;
import com.czkevin.cif.commands.CIFMainCommand;
import de.tr7zw.nbtapi.NBTContainer;
import de.tr7zw.nbtapi.NBTItem;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

public class ShowNBTCommand implements CIFSubCommand {
    @Override
    public String getCommandName() {
        return "nbt";
    }

    @Override
    public String getHelpParameters() {
        return "";
    }

    @Override
    public String getHelpText() {
        return "Display NBT of the item you're holding. ";
    }

    @Override
    public void execute(CommandSender sender, String[] args) {
        if(!sender.hasPermission(CIFMainCommand.PERMISSION)) return;
        if(!Player.class.isAssignableFrom(sender.getClass())) return;
        Player player = (Player) sender;
        NBTContainer nbt = NBTItem.convertItemtoNBT(player.getInventory().getItemInMainHand());
        player.sendMessage(nbt.toString());
    }
}
